﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace Test2020
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> alist = new List<int>();
            for (int i = 0; i < 10000000; i++)
            {
                alist.Add(i);
            }
            Stopwatch stopwatch = Stopwatch.StartNew();
            var list = alist.Where(x => x > 5);
            list = list.Where(x => x > 6);
            list = list.Where(x => x > 7);
            list = list.Where(x => x > 8);
            list = list.Where(x => x > 9);
            list = list.ToList();
            Console.WriteLine($"不tolist耗时：{stopwatch.ElapsedMilliseconds}ms");
            stopwatch.Restart();
            var list1 = alist.Where(x => x > 5).ToList();
            list1 = list1.Where(x => x > 6).ToList();
            list1 = list1.Where(x => x > 7).ToList();
            list1 = list1.Where(x => x > 8).ToList();
            list1 = list1.Where(x => x > 9).ToList();
            Console.WriteLine($"tolist耗时{stopwatch.ElapsedMilliseconds}ms");
            Console.ReadLine();

            Person a = new Person() { Name = "123456" };
            Person b = new Person() { Name = "123459" };
            Person c = new Person() { Name = "123458" };
            Person e = new Person() { Name = "12345a" };
            List<Person> aaa = new List<Person>() { a, b, c,e };
            var result= aaa.OrderBy(x=>x.Name);
            var d= result.ToList();
        }
    }
    public class Person
    {
        public string Name { get; set; }
    }
}
